#include <vector>
#include <queue>

using namespace std;

class Solution {
public:
    void wiggleSort(vector<int>& nums) {
        priority_queue<int, vector<int>, greater<int>> queue;
        for (int num : nums) {
            queue.push(num);
        }
        for (int i = nums.size() % 2 == 1 ? nums.size() - 1 : nums.size() - 2; i >= 0; i -= 2) {
            nums[i] = queue.top();
            queue.pop();
        }
        for (int i = nums.size() % 2 == 1 ? nums.size() - 2 : nums.size() - 1; i >= 0; i -= 2) {
            nums[i] = queue.top();
            queue.pop();
        }
    }
};